{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%run main.py\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "!mkdir -p {RAW_DIR}\n",
    "s3 = S3()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# !wget https://storage.yandexcloud.net/natasha-corus/collection5.zip -P {RAW_DIR}\n",
    "# !wget https://storage.yandexcloud.net/natasha-corus/factRuEval-2016-master.zip -P {RAW_DIR}\n",
    "# !unzip {RAW_DIR}/collection5.zip -d {RAW_DIR}\n",
    "# !unzip {RAW_DIR}/factRuEval-2016-master.zip -d {RAW_DIR}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "settings = [\n",
    "    (CORUS_NE5, NE5, S3_NE5, load_ne5),\n",
    "    (CORUS_FACTRU, FACTRU, S3_FACTRU, load_factru)\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for source, target, _, load in settings:\n",
    "    records = load(source)\n",
    "    records = log_progress(records, desc=load.__name__)\n",
    "    records = (_.adapted for _ in records)\n",
    "    items = (_.as_json for _ in records)\n",
    "    lines = format_jl(items)\n",
    "    dump_gz_lines(lines, target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for _, source, target, _ in log_progress(settings):\n",
    "    s3.upload(source, target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
